home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / doom / quake.zip / PW_DOE.ZIP / WEAPONS.QC < prev   
Text File  |  1997-05-01  |  38KB  |  1,769 lines

  1. /*
  2. */
  3.  
  4. float lavaGunFired;
  5.  
  6. void (entity targ, entity inflictor, entity attacker, float damage) T_Damage;
  7. void () player_run;
  8. void(entity bomb, entity attacker, float rad, entity ignore) T_RadiusDamage;
  9. void(vector org, vector vel, float damage) SpawnBlood;
  10. void() SuperDamageSound;
  11.  
  12.  
  13. // called by worldspawn
  14. void() W_Precache =
  15. {
  16.     precache_sound ("weapons/r_exp3.wav");    // new rocket explosion
  17.     precache_sound ("weapons/rocket1i.wav");    // spike gun
  18.     precache_sound ("weapons/sgun1.wav");
  19.     precache_sound ("weapons/guncock.wav");    // player shotgun
  20.     precache_sound ("weapons/ric1.wav");    // ricochet (used in c code)
  21.     precache_sound ("weapons/ric2.wav");    // ricochet (used in c code)
  22.     precache_sound ("weapons/ric3.wav");    // ricochet (used in c code)
  23.     precache_sound ("weapons/spike2.wav");    // super spikes
  24.     precache_sound ("weapons/tink1.wav");    // spikes tink (used in c code)
  25.     precache_sound ("weapons/grenade.wav");    // grenade launcher
  26.     precache_sound ("weapons/bounce.wav");        // grenade bounce
  27.     precache_sound ("weapons/shotgn2.wav");    // super shotgun
  28.  
  29. //ZOID--
  30.     // grapple
  31.     precache_sound("weapons/chain1.wav");
  32. //    precache_sound("weapons/chain2.wav");
  33. //    precache_sound("weapons/chain3.wav");
  34. //    precache_sound("weapons/bounce2.wav");
  35. //    precache_sound("blob/land1.wav");
  36.     precache_sound("pendulum/hit.wav");
  37. //--ZOID
  38.  
  39.     precache_sound ("lavagun/snail.wav");        // lava nail gun cooldown
  40. };
  41.  
  42. float() crandom =
  43. {
  44.     return 2*(random() - 0.5);
  45. };
  46.  
  47. /*
  48. ================
  49. W_FireAxe
  50. ================
  51. */
  52. void() W_FireAxe =
  53. {
  54.     local    vector    source;
  55.     local    vector    org;
  56.  
  57.     makevectors (self.v_angle);
  58.     source = self.origin + '0 0 16';
  59.     traceline (source, source + v_forward*64, FALSE, self);
  60.     if (trace_fraction == 1.0)
  61.         return;
  62.     
  63.     org = trace_endpos - v_forward*4;
  64.  
  65.     if (trace_ent.takedamage)
  66.     {
  67.         trace_ent.axhitme = 1;
  68.         SpawnBlood (org, '0 0 0', 20);
  69.         T_Damage (trace_ent, self, self, 20);
  70.     }
  71.     else
  72.     {    // hit wall
  73.         sound (self, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM);
  74.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  75.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  76.         WriteCoord (MSG_BROADCAST, org_x);
  77.         WriteCoord (MSG_BROADCAST, org_y);
  78.         WriteCoord (MSG_BROADCAST, org_z);
  79.     }
  80. };
  81.  
  82.  
  83. //============================================================================
  84.  
  85.  
  86. vector() wall_velocity =
  87. {
  88.     local vector    vel;
  89.     
  90.     vel = normalize (self.velocity);
  91.     vel = normalize(vel + v_up*(random()- 0.5) + v_right*(random()- 0.5));
  92.     vel = vel + 2*trace_plane_normal;
  93.     vel = vel * 200;
  94.     
  95.     return vel;
  96. };
  97.  
  98.  
  99. /*
  100. ================
  101. SpawnMeatSpray
  102. ================
  103. */
  104. void(vector org, vector vel) SpawnMeatSpray =
  105. {
  106.     local    entity missile, mpuff;
  107.     local    vector    org;
  108.  
  109.     missile = spawn ();
  110.     missile.owner = self;
  111.     missile.movetype = MOVETYPE_BOUNCE;
  112.     missile.solid = SOLID_NOT;
  113.  
  114.     makevectors (self.angles);
  115.  
  116.     missile.velocity = vel;
  117.     missile.velocity_z = missile.velocity_z + 250 + 50*random();
  118.  
  119.     missile.avelocity = '3000 1000 2000';
  120.     
  121. // set missile duration
  122.     missile.nextthink = time + 1;
  123.     missile.think = SUB_Remove;
  124.  
  125.     setmodel (missile, "progs/zom_gib.mdl");
  126.     setsize (missile, '0 0 0', '0 0 0');        
  127.     setorigin (missile, org);
  128. };
  129.  
  130. /*
  131. ================
  132. SpawnBlood
  133. ================
  134. */
  135. void(vector org, vector vel, float damage) SpawnBlood =
  136. {
  137.     particle (org, vel*0.1, 73, damage*2);
  138. };
  139.  
  140. /*
  141. ================
  142. spawn_touchblood
  143. ================
  144. */
  145. void(float damage) spawn_touchblood =
  146. {
  147.     local vector    vel;
  148.  
  149.     vel = wall_velocity () * 0.2;
  150.     SpawnBlood (self.origin + vel*0.01, vel, damage);
  151. };
  152.  
  153.  
  154. /*
  155. ================
  156. SpawnChunk
  157. ================
  158. */
  159. void(vector org, vector vel) SpawnChunk =
  160. {
  161.     particle (org, vel*0.02, 0, 10);
  162. };
  163.  
  164. /*
  165. ==============================================================================
  166.  
  167. MULTI-DAMAGE
  168.  
  169. Collects multiple small damages into a single damage
  170.  
  171. ==============================================================================
  172. */
  173.  
  174. entity    multi_ent;
  175. float    multi_damage;
  176.  
  177. void() ClearMultiDamage =
  178. {
  179.     multi_ent = world;
  180.     multi_damage = 0;
  181. };
  182.  
  183. void() ApplyMultiDamage =
  184. {
  185.     if (!multi_ent)
  186.         return;
  187.     T_Damage (multi_ent, self, self, multi_damage);
  188. };
  189.  
  190. void(entity hit, float damage) AddMultiDamage =
  191. {
  192.     if (!hit)
  193.         return;
  194.     
  195.     if (hit != multi_ent)
  196.     {
  197.         ApplyMultiDamage ();
  198.         multi_damage = damage;
  199.         multi_ent = hit;
  200.     }
  201.     else
  202.         multi_damage = multi_damage + damage;
  203. };
  204.  
  205. /*
  206. ==============================================================================
  207.  
  208. BULLETS
  209.  
  210. ==============================================================================
  211. */
  212.  
  213. /*
  214. ================
  215. TraceAttack
  216. ================
  217. */
  218. void(float damage, vector dir) TraceAttack =
  219. {
  220.     local    vector    vel, org;
  221.     
  222.     vel = normalize(dir + v_up*crandom() + v_right*crandom());
  223.     vel = vel + 2*trace_plane_normal;
  224.     vel = vel * 200;
  225.  
  226.     org = trace_endpos - dir*4;
  227.  
  228.     if (trace_ent.takedamage)
  229.     {
  230.         SpawnBlood (org, vel*0.2, damage);
  231.         AddMultiDamage (trace_ent, damage);
  232.     }
  233.     else
  234.     {
  235.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  236.         WriteByte (MSG_BROADCAST, TE_GUNSHOT);
  237.         WriteCoord (MSG_BROADCAST, org_x);
  238.         WriteCoord (MSG_BROADCAST, org_y);
  239.         WriteCoord (MSG_BROADCAST, org_z);
  240.     }
  241. };
  242.  
  243. /*
  244. ================
  245. FireBullets
  246.  
  247. Used by shotgun, super shotgun, and enemy soldier firing
  248. Go to the trouble of combining multiple pellets into a single damage call.
  249. ================
  250. */
  251. void(float shotcount, vector dir, vector spread) FireBullets =
  252. {
  253.     local    vector direction;
  254.     local    vector    src;
  255.     
  256.     makevectors(self.v_angle);
  257.  
  258.     src = self.origin + v_forward*10;
  259.     src_z = self.absmin_z + self.size_z * 0.7;
  260.  
  261.     ClearMultiDamage ();
  262.     while (shotcount > 0)
  263.     {
  264.         direction = dir + crandom()*spread_x*v_right + crandom()*spread_y*v_up;
  265.  
  266.         traceline (src, src + direction*2048, FALSE, self);
  267.         if (trace_fraction != 1.0)
  268.             TraceAttack (4, direction);
  269.  
  270.         shotcount = shotcount - 1;
  271.     }
  272.     ApplyMultiDamage ();
  273. };
  274.  
  275. /*
  276. ================
  277. W_FireShotgun
  278. ================
  279. */
  280. void() W_FireShotgun =
  281. {
  282.     local vector dir;
  283.  
  284.     sound (self, CHAN_WEAPON, "weapons/guncock.wav", 1, ATTN_NORM);    
  285.  
  286.     self.punchangle_x = -2;
  287.     
  288.     self.currentammo = self.ammo_shells1 = self.ammo_shells1 - 1;
  289.     UpdateAmmoCounts(self);
  290.     dir = aim (self, 100000);
  291.     FireBullets (6, dir, '0.04 0.04 0');
  292. };
  293.  
  294.  
  295. /*
  296. ================
  297. W_FireSuperShotgun
  298. ================
  299. */
  300. void() W_FireSuperShotgun =
  301. {
  302.     local vector dir;
  303.  
  304.     if (self.currentammo == 1)
  305.     {
  306.         W_FireShotgun ();
  307.         return;
  308.     }
  309.         
  310.     sound (self ,CHAN_WEAPON, "weapons/shotgn2.wav", 1, ATTN_NORM);    
  311.  
  312.     self.punchangle_x = -4;
  313.     
  314.     self.currentammo = self.ammo_shells1 = self.ammo_shells1 - 2;
  315.     UpdateAmmoCounts(self);
  316.     dir = aim (self, 100000);
  317.     FireBullets (14, dir, '0.14 0.08 0');
  318. };
  319.  
  320.  
  321. /*
  322. ==============================================================================
  323.  
  324. ROCKETS
  325.  
  326. ==============================================================================
  327. */
  328.  
  329. void()    s_explode1    =    [0,        s_explode2] {};
  330. void()    s_explode2    =    [1,        s_explode3] {};
  331. void()    s_explode3    =    [2,        s_explode4] {};
  332. void()    s_explode4    =    [3,        s_explode5] {};
  333. void()    s_explode5    =    [4,        s_explode6] {};
  334. void()    s_explode6    =    [5,        SUB_Remove] {};
  335.  
  336. void() BecomeExplosion =
  337. {
  338.     self.movetype = MOVETYPE_NONE;
  339.     self.velocity = '0 0 0';
  340.     self.touch = SUB_Null;
  341.     setmodel (self, "progs/s_explod.spr");
  342.     self.solid = SOLID_NOT;
  343.     s_explode1 ();
  344. };
  345.  
  346. void() T_MissileTouch =
  347. {
  348.     local float    damg;
  349.  
  350.     if (other == self.owner)
  351.         return;        // don't explode on owner
  352.  
  353.     if (pointcontents(self.origin) == CONTENT_SKY)
  354.     {
  355.         remove(self);
  356.         return;
  357.     }
  358.  
  359.     damg = 100 + random()*20;
  360.     
  361.     if (other.health)
  362.     {
  363.         if (other.classname == "monster_shambler")
  364.             damg = damg * 0.5;    // mostly immune
  365.         T_Damage (other, self, self.owner, damg );
  366.     }
  367.  
  368.     // don't do radius damage to the other, because all the damage
  369.     // was done in the impact
  370.     T_RadiusDamage (self, self.owner, 120, other);
  371.  
  372. //    sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
  373.     self.origin = self.origin - 8*normalize(self.velocity);
  374.  
  375.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  376.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  377.     WriteCoord (MSG_BROADCAST, self.origin_x);
  378.     WriteCoord (MSG_BROADCAST, self.origin_y);
  379.     WriteCoord (MSG_BROADCAST, self.origin_z);
  380.  
  381.     BecomeExplosion ();
  382. };
  383.  
  384.  
  385.  
  386. /*
  387. ================
  388. W_FireRocket
  389. ================
  390. */
  391. void() W_FireRocket =
  392. {
  393.     local    entity missile, mpuff;
  394.     
  395.     self.currentammo = self.ammo_rockets1 = self.ammo_rockets1 - 1;
  396.     UpdateAmmoCounts(self);
  397.     
  398.     sound (self, CHAN_WEAPON, "weapons/sgun1.wav", 1, ATTN_NORM);
  399.  
  400.     self.punchangle_x = -2;
  401.  
  402.     missile = spawn ();
  403.     missile.owner = self;
  404.     missile.movetype = MOVETYPE_FLYMISSILE;
  405.     missile.solid = SOLID_BBOX;
  406.     missile.classname = "missile";
  407.     
  408. // set missile speed    
  409.  
  410.     makevectors (self.v_angle);
  411.     missile.velocity = aim(self, 1000);
  412.     missile.velocity = missile.velocity * 1000;
  413.     missile.angles = vectoangles(missile.velocity);
  414.     
  415.     missile.touch = T_MissileTouch;
  416.     
  417. // set missile duration
  418.     missile.nextthink = time + 5;
  419.     missile.think = SUB_Remove;
  420.  
  421.     setmodel (missile, "progs/missile.mdl");
  422.     setsize (missile, '0 0 0', '0 0 0');        
  423.     setorigin (missile, self.origin + v_forward*8 + '0 0 16');
  424. };
  425.  
  426. /*
  427. ===============================================================================
  428.  
  429. LIGHTNING
  430.  
  431. ===============================================================================
  432. */
  433.  
  434. /*
  435. =================
  436. LightningDamage
  437. =================
  438. */
  439. void(vector p1, vector p2, entity from, float damage) LightningDamage =
  440. {
  441.     local entity        e1, e2;
  442.     local vector        f;
  443.     
  444.     f = p2 - p1;
  445.     normalize (f);
  446.     f_x = 0 - f_y;
  447.     f_y = f_x;
  448.     f_z = 0;
  449.     f = f*16;
  450.  
  451.     e1 = e2 = world;
  452.  
  453.     traceline (p1, p2, FALSE, self);
  454.     if (trace_ent.takedamage)
  455.     {
  456.         particle (trace_endpos, '0 0 100', 225, damage*4);
  457.         T_Damage (trace_ent, from, from, damage);
  458.         if (self.classname == "player")
  459.         {
  460.             if (other.classname == "player")
  461.                 trace_ent.velocity_z = trace_ent.velocity_z + 400;
  462.         }
  463.     }
  464.     e1 = trace_ent;
  465.  
  466.     traceline (p1 + f, p2 + f, FALSE, self);
  467.     if (trace_ent != e1 && trace_ent.takedamage)
  468.     {
  469.         particle (trace_endpos, '0 0 100', 225, damage*4);
  470.         T_Damage (trace_ent, from, from, damage);
  471.     }
  472.     e2 = trace_ent;
  473.  
  474.     traceline (p1 - f, p2 - f, FALSE, self);
  475.     if (trace_ent != e1 && trace_ent != e2 && trace_ent.takedamage)
  476.     {
  477.         particle (trace_endpos, '0 0 100', 225, damage*4);
  478.         T_Damage (trace_ent, from, from, damage);
  479.     }
  480. };
  481.  
  482.  
  483. void() W_FireLightning =
  484. {
  485.     local    vector        org;
  486.     local    float        cells;
  487.  
  488.     if (self.ammo_cells1 < 1)
  489.     {
  490.         self.weapon = W_BestWeapon ();
  491.         W_SetCurrentAmmo ();
  492.         return;
  493.     }
  494.  
  495. // explode if under water
  496.     if (self.waterlevel > 1)
  497.     {
  498.         cells = self.ammo_cells1;
  499.         self.ammo_cells1 = 0;
  500.         W_SetCurrentAmmo ();
  501.         T_RadiusDamage (self, self, 35*cells, world);
  502.         return;
  503.     }
  504.  
  505.     if (self.t_width < time)
  506.     {
  507.         sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
  508.         self.t_width = time + 0.6;
  509.     }
  510.     self.punchangle_x = -2;
  511.  
  512.     self.currentammo = self.ammo_cells1 = self.ammo_cells1 - 1;
  513.     UpdateAmmoCounts(self);
  514.  
  515.     org = self.origin + '0 0 16';
  516.     
  517.     makevectors (self.v_angle);
  518.     traceline (org, org + v_forward*600, TRUE, self);
  519.  
  520.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  521.     WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
  522.     WriteEntity (MSG_BROADCAST, self);
  523.     WriteCoord (MSG_BROADCAST, org_x);
  524.     WriteCoord (MSG_BROADCAST, org_y);
  525.     WriteCoord (MSG_BROADCAST, org_z);
  526.     WriteCoord (MSG_BROADCAST, trace_endpos_x);
  527.     WriteCoord (MSG_BROADCAST, trace_endpos_y);
  528.     WriteCoord (MSG_BROADCAST, trace_endpos_z);
  529.  
  530.     LightningDamage (self.origin + '0 0 16', trace_endpos + v_forward*4, self, 30);
  531. };
  532.  
  533.  
  534. //=============================================================================
  535.  
  536.  
  537. void() GrenadeExplode =
  538. {
  539.     T_RadiusDamage (self, self.owner, 120, world);
  540.  
  541.     WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  542.     WriteByte (MSG_BROADCAST, TE_EXPLOSION);
  543.     WriteCoord (MSG_BROADCAST, self.origin_x);
  544.     WriteCoord (MSG_BROADCAST, self.origin_y);
  545.     WriteCoord (MSG_BROADCAST, self.origin_z);
  546.  
  547.     BecomeExplosion ();
  548. };
  549.  
  550. void() GrenadeTouch =
  551. {
  552.     if (other == self.owner)
  553.         return;        // don't explode on owner
  554.  
  555.     if (other.takedamage == DAMAGE_AIM)
  556.     {
  557.         GrenadeExplode();
  558.         return;
  559.     }
  560.     sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);    // bounce sound
  561.     if (self.velocity == '0 0 0')
  562.         self.avelocity = '0 0 0';
  563. };
  564.  
  565. /*
  566. ================
  567. W_FireGrenade
  568. ================
  569. */
  570. void() W_FireGrenade =
  571. {
  572.     local    entity missile, mpuff;
  573.     
  574.     self.currentammo = self.ammo_rockets1 = self.ammo_rockets1 - 1;
  575.     UpdateAmmoCounts(self);
  576.     
  577.     sound (self, CHAN_WEAPON, "weapons/grenade.wav", 1, ATTN_NORM);
  578.  
  579.     self.punchangle_x = -2;
  580.  
  581.     missile = spawn ();
  582.     missile.owner = self;
  583.     missile.movetype = MOVETYPE_BOUNCE;
  584.     missile.solid = SOLID_BBOX;
  585.     missile.classname = "grenade";
  586.         
  587. // set missile speed    
  588.  
  589.     makevectors (self.v_angle);
  590.  
  591.     if (self.v_angle_x)
  592.         missile.velocity = v_forward*600 + v_up * 200 + crandom()*v_right*10 + crandom()*v_up*10;
  593.     else
  594.     {
  595.         missile.velocity = aim(self, 10000);
  596.         missile.velocity = missile.velocity * 600;
  597.         missile.velocity_z = 200;
  598.     }
  599.  
  600.     missile.avelocity = '300 300 300';
  601.  
  602.     missile.angles = vectoangles(missile.velocity);
  603.     
  604.     missile.touch = GrenadeTouch;
  605.     
  606. // set missile duration
  607.     missile.nextthink = time + 2.5;
  608.     missile.think = GrenadeExplode;
  609.  
  610.     setmodel (missile, "progs/grenade.mdl");
  611.     setsize (missile, '0 0 0', '0 0 0');        
  612.     setorigin (missile, self.origin);
  613. };
  614.  
  615.  
  616. //=============================================================================
  617.  
  618. void() spike_touch;
  619. void() superspike_touch;
  620. void() lavaspike_touch;
  621. void() superlavaspike_touch;
  622.  
  623. /*
  624. ===============
  625. launch_spike
  626.  
  627. Used for both the player and the ogre
  628. ===============
  629. */
  630. void(vector org, vector dir) launch_spike =
  631. {
  632.     newmis = spawn ();
  633.     newmis.owner = self;
  634.     newmis.movetype = MOVETYPE_FLYMISSILE;
  635.     newmis.solid = SOLID_BBOX;
  636.  
  637.     newmis.angles = vectoangles(dir);
  638.     
  639.     newmis.touch = spike_touch;
  640.     newmis.classname = "spike";
  641.     newmis.think = SUB_Remove;
  642.     newmis.nextthink = time + 6;
  643.     setmodel (newmis, "progs/spike.mdl");
  644.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);        
  645.     setorigin (newmis, org);
  646.  
  647.     newmis.velocity = dir * 1000;
  648. };
  649.  
  650. void() W_FireSuperSpikes =
  651. {
  652.     local vector    dir;
  653.     local entity    old;
  654.     
  655.     sound (self, CHAN_WEAPON, "weapons/spike2.wav", 1, ATTN_NORM);
  656.     self.attack_finished = time + 0.2;
  657.  
  658.     self.currentammo = self.ammo_nails1 = self.ammo_nails1 - 2;
  659.     UpdateAmmoCounts(self);
  660.  
  661.     dir = aim (self, 1000);
  662.     launch_spike (self.origin + '0 0 16', dir);
  663.     newmis.touch = superspike_touch;
  664.     setmodel (newmis, "progs/s_spike.mdl");
  665.     setsize (newmis, VEC_ORIGIN, VEC_ORIGIN);            
  666.     self.punchangle_x = -2;
  667. };
  668.  
  669. void(float ox) W_FireSpikes =
  670. {
  671.     local vector    dir;
  672.     local entity    old;
  673.     
  674.     makevectors (self.v_angle);
  675.     
  676.     if (self.ammo_nails1 >= 2 && self.weapon == IT_SUPER_NAILGUN)
  677.     {
  678.         W_FireSuperSpikes ();
  679.         return;
  680.     }
  681.  
  682.     if (self.ammo_nails1 < 1)
  683.     {
  684.         self.weapon = W_BestWeapon ();
  685.         W_SetCurrentAmmo ();
  686.         return;
  687.     }
  688.  
  689.     sound (self, CHAN_WEAPON, "weapons/rocket1i.wav", 1, ATTN_NORM);
  690.     self.attack_finished = time + 0.2;
  691.     self.currentammo = self.ammo_nails1 = self.ammo_nails1 - 1;
  692.     UpdateAmmoCounts(self);
  693.  
  694.     dir = aim (self, 1000);
  695.     launch_spike (self.origin + '0 0 16' + v_right*ox, dir);
  696.  
  697.     self.punchangle_x = -2;
  698. };
  699.  
  700. .float hit_z;
  701. void() spike_touch =
  702. {
  703. local float rand;
  704.     if (other == self.owner)
  705.         return;
  706.  
  707.     if (other.solid == SOLID_TRIGGER)
  708.         return;    // trigger field, do nothing
  709.  
  710.     if (pointcontents(self.origin) == CONTENT_SKY)
  711.     {
  712.         remove(self);
  713.         return;
  714.     }
  715.     
  716. // hit something that bleeds
  717.     if (other.takedamage)
  718.     {
  719.         spawn_touchblood (9);
  720.         T_Damage (other, self, self.owner, 9);
  721.     }
  722.     else
  723.     {
  724.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  725.         
  726.         if (self.classname == "wizspike")
  727.             WriteByte (MSG_BROADCAST, TE_WIZSPIKE);
  728.         else if (self.classname == "knightspike")
  729.             WriteByte (MSG_BROADCAST, TE_KNIGHTSPIKE);
  730.         else
  731.             WriteByte (MSG_BROADCAST, TE_SPIKE);
  732.         WriteCoord (MSG_BROADCAST, self.origin_x);
  733.         WriteCoord (MSG_BROADCAST, self.origin_y);
  734.         WriteCoord (MSG_BROADCAST, self.origin_z);
  735.     }
  736.  
  737.     remove(self);
  738.  
  739. };
  740.  
  741. void() superspike_touch =
  742. {
  743. local float rand;
  744.     if (other == self.owner)
  745.         return;
  746.  
  747.     if (other.solid == SOLID_TRIGGER)
  748.         return;    // trigger field, do nothing
  749.  
  750.     if (pointcontents(self.origin) == CONTENT_SKY)
  751.     {
  752.         remove(self);
  753.         return;
  754.     }
  755.     
  756. // hit something that bleeds
  757.     if (other.takedamage)
  758.     {
  759.         spawn_touchblood (18);
  760.         T_Damage (other, self, self.owner, 18);
  761.     }
  762.     else
  763.     {
  764.         WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  765.         WriteByte (MSG_BROADCAST, TE_SUPERSPIKE);
  766.         WriteCoord (MSG_BROADCAST, self.origin_x);
  767.         WriteCoord (MSG_BROADCAST, self.origin_y);
  768.         WriteCoord (MSG_BROADCAST, self.origin_z);
  769.     }
  770.  
  771.     remove(self);
  772.  
  773. };
  774.  
  775. /*
  776. ===============================================================================
  777.  
  778. PLAYER WEAPON USE
  779.  
  780. ===============================================================================
  781. */
  782.  
  783. void() W_SetCurrentAmmo =
  784. {
  785.     player_run ();        // get out of any weapon firing states
  786.  
  787.     self.items = self.items - 
  788.         ( self.items & (IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS));
  789.     self.items2 = self.items2 - 
  790.         (self.items2 & (IT2_LAVA_NAILS|IT2_PLASMA_AMMO|IT2_MULTI_ROCKETS));
  791.     
  792.     if (self.weapon == IT_AXE)
  793.     {
  794.         self.currentammo = 0;
  795.         self.weaponmodel = "progs/v_axe.mdl";
  796.         self.weaponframe = 0;
  797.     }
  798. //ZOID--
  799.     else if (self.weapon == IT_GRAPPLE)
  800.     {
  801.         self.currentammo = 0;
  802.         self.weaponmodel = "progs/v_grpple.mdl";
  803.         self.weaponframe = 0;
  804.     }
  805. //--ZOID
  806.     else if (self.weapon == IT_SHOTGUN)
  807.     {
  808.         self.currentammo = self.ammo_shells1;
  809.         self.weaponmodel = "progs/v_shot.mdl";
  810.         self.weaponframe = 0;
  811.         self.items = self.items | IT_SHELLS;
  812.     }
  813.     else if (self.weapon == IT_SUPER_SHOTGUN)
  814.     {
  815.         self.currentammo = self.ammo_shells1;
  816.         self.weaponmodel = "progs/v_shot2.mdl";
  817.         self.weaponframe = 0;
  818.         self.items = self.items | IT_SHELLS;
  819.     }
  820.     else if (self.weapon == IT_LAVA_NAILGUN)
  821.     {
  822.         self.currentammo = self.ammo_lava_nails;
  823.         self.weaponmodel = "progs/v_lava.mdl";
  824.         self.weaponframe = 0;
  825.         self.items2 = self.items2 | IT2_LAVA_NAILS;
  826.     }
  827.     else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  828.     {
  829.         self.currentammo = self.ammo_lava_nails;
  830.         self.weaponmodel = "progs/v_lava2.mdl";
  831.         self.weaponframe = 0;
  832.         self.items2 = self.items2 | IT2_LAVA_NAILS;
  833.     }
  834.     else if (self.weapon == IT_MULTI_GRENADE)
  835.     {
  836.         self.currentammo = self.ammo_multi_rockets;
  837.         self.weaponmodel = "progs/v_multi.mdl";
  838.         self.weaponframe = 0;
  839.         self.items2 = self.items2 | IT2_MULTI_ROCKETS;
  840.     }
  841.     else if (self.weapon == IT_MULTI_ROCKET)
  842.     {            
  843.         self.currentammo = self.ammo_multi_rockets;
  844.         self.weaponmodel = "progs/v_multi2.mdl";
  845.         self.weaponframe = 0;
  846.         self.items2 = self.items2 | IT2_MULTI_ROCKETS;
  847.     }
  848.     else if (self.weapon == IT_PLASMA_GUN)
  849.     {
  850.         self.currentammo = self.ammo_plasma;
  851.         self.weaponmodel = "progs/v_plasma.mdl";
  852.         self.weaponframe = 0;
  853.         self.items2 = self.items2 | IT2_PLASMA_AMMO;
  854.     }
  855.     else if (self.weapon == IT_NAILGUN)
  856.     {
  857.         self.currentammo = self.ammo_nails1;
  858.         self.weaponmodel = "progs/v_nail.mdl";
  859.         self.weaponframe = 0;
  860.         self.items = self.items | IT_NAILS;
  861.     }
  862.     else if (self.weapon == IT_SUPER_NAILGUN)
  863.     {
  864.         self.currentammo = self.ammo_nails1;
  865.         self.weaponmodel = "progs/v_nail2.mdl";
  866.         self.weaponframe = 0;
  867.         self.items = self.items | IT_NAILS;
  868.     }
  869.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  870.     {
  871.         self.currentammo = self.ammo_rockets1;
  872.         self.weaponmodel = "progs/v_rock.mdl";
  873.         self.weaponframe = 0;
  874.         self.items = self.items | IT_ROCKETS;
  875.     }
  876.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  877.     {
  878.         self.currentammo = self.ammo_rockets1;
  879.         self.weaponmodel = "progs/v_rock2.mdl";
  880.         self.weaponframe = 0;
  881.         self.items = self.items | IT_ROCKETS;
  882.     }
  883.     else if (self.weapon == IT_LIGHTNING)
  884.     {
  885.         self.currentammo = self.ammo_cells1;
  886.         self.weaponmodel = "progs/v_light.mdl";
  887.         self.weaponframe = 0;
  888.         self.items = self.items | IT_CELLS;
  889.     }
  890.     else
  891.     {
  892.         self.currentammo = 0;
  893.         self.weaponmodel = "";
  894.         self.weaponframe = 0;
  895.     }        
  896.     UpdateAmmoCounts(self);
  897. };
  898.  
  899. float() W_BestWeapon =
  900. {
  901.     local    float    it;
  902.  
  903.     it = self.items;
  904.  
  905. // pgm - fix for sandy. will not change to plasma gun
  906.     
  907. //    if(self.waterlevel <= 1 && self.ammo_plasma >= 1 && (it & IT_PLASMA_GUN))
  908. //        return IT_PLASMA_GUN;
  909. //    else 
  910.     if(self.waterlevel<=1 && self.ammo_cells1>=1 && (it & IT_LIGHTNING))
  911.         return IT_LIGHTNING;
  912.     else if(self.ammo_lava_nails >= 2 && (it & IT_LAVA_SUPER_NAILGUN) )
  913.         return IT_LAVA_SUPER_NAILGUN;
  914.     else if(self.ammo_nails1 >= 2 && (it & IT_SUPER_NAILGUN) )
  915.         return IT_SUPER_NAILGUN;
  916.     else if(self.ammo_lava_nails >= 1 && (it & IT_LAVA_NAILGUN) )
  917.         return IT_LAVA_NAILGUN;
  918.     else if(self.ammo_nails1 >= 1 && (it & IT_NAILGUN) )
  919.         return IT_NAILGUN;
  920.     else if(self.ammo_shells1 >= 2 && (it & IT_SUPER_SHOTGUN) )
  921.         return IT_SUPER_SHOTGUN;
  922.     else if(self.ammo_shells1 >= 1 && (it & IT_SHOTGUN) )
  923.         return IT_SHOTGUN;
  924.         
  925.     return IT_AXE;
  926. };
  927.  
  928. float() W_CheckNoAmmo =
  929. {
  930.     if (self.currentammo > 0)
  931.         return TRUE;
  932.  
  933. //ZOID--
  934.     if (self.weapon == IT_AXE || self.weapon == IT_GRAPPLE)
  935.         return TRUE;
  936. //--ZOID
  937.     
  938.     self.weapon = W_BestWeapon ();
  939.  
  940.     W_SetCurrentAmmo ();
  941.     
  942. // drop the weapon down
  943.     return FALSE;
  944. };
  945.  
  946. /*
  947. ============
  948. W_Attack
  949.  
  950. An attack impulse can be triggered now
  951. ============
  952. */
  953. void()    player_axe1;
  954. void()    player_axeb1;
  955. void()    player_axec1;
  956. void()    player_axed1;
  957. void()    player_shot1;
  958. void()    player_nail1;
  959. void()    player_light1;
  960. void()    player_rocket1;
  961. void()    player_lava_nail1;
  962. //ZOID--
  963. void()  player_grapple1;
  964. void()  player_grapple3;
  965. //--ZOID
  966.  
  967. void() W_FireMultiGrenade;
  968. void() W_FireMultiRocket;
  969.  
  970. void() W_Attack =
  971. {
  972.     local    float    r;
  973.  
  974.     if (!W_CheckNoAmmo ())
  975.         return;
  976.  
  977.     makevectors    (self.v_angle);        // calculate forward angle for velocity
  978.     self.show_hostile = time + 1;    // wake monsters up
  979.  
  980. // ZOID--
  981.     RuneApplyBlackNoise(self); // make rune noise
  982. //--ZOID
  983.  
  984.     if (self.weapon == IT_AXE)
  985.     {
  986.         sound (self, CHAN_WEAPON, "weapons/ax1.wav", 1, ATTN_NORM);
  987.         r = random();
  988.         if (r < 0.25)
  989.             player_axe1 ();
  990.         else if (r<0.5)
  991.             player_axeb1 ();
  992.         else if (r<0.75)
  993.             player_axec1 ();
  994.         else
  995.             player_axed1 ();
  996.         self.attack_finished = time + RuneApplyHell(0.5, self);
  997.     }
  998. //ZOID--
  999.     else if (self.weapon == IT_GRAPPLE)
  1000.     {
  1001.         if (!self.hook_out)
  1002.             player_grapple1();
  1003.         else
  1004.             player_grapple3();
  1005.         self.attack_finished = time + 0.1;
  1006.     }
  1007. //--ZOID
  1008.     else if (self.weapon == IT_SHOTGUN)
  1009.     {
  1010.         player_shot1 ();
  1011.         W_FireShotgun ();
  1012.         self.attack_finished = time + RuneApplyHell(0.5, self);
  1013.     }
  1014.     else if (self.weapon == IT_SUPER_SHOTGUN)
  1015.     {
  1016.         player_shot1 ();
  1017.         W_FireSuperShotgun ();
  1018.         self.attack_finished = time + RuneApplyHell(0.7, self);
  1019.     }
  1020.     else if (self.weapon == IT_LAVA_NAILGUN)
  1021.     {
  1022.         lavaGunFired = 1;
  1023.         player_lava_nail1 ();
  1024.     }
  1025.     else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  1026.     {
  1027.         lavaGunFired = 1;
  1028.         player_lava_nail1 ();
  1029.     }
  1030.     else if (self.weapon == IT_MULTI_GRENADE)
  1031.     {
  1032.         player_rocket1();
  1033.         W_FireMultiGrenade();
  1034.         self.attack_finished = time + RuneApplyHell(0.6, self);
  1035.     }
  1036.     else if (self.weapon == IT_MULTI_ROCKET)
  1037.     {
  1038.         player_rocket1();
  1039.         W_FireMultiRocket();
  1040.         self.attack_finished = time + RuneApplyHell(0.8, self);
  1041.     }
  1042.     else if (self.weapon == IT_PLASMA_GUN)
  1043.     {
  1044.         // player_light1 determines choice of W_FireLightning 
  1045.         //    or W_FirePlasma, but same lighting and frames...
  1046.         self.attack_finished = time + RuneApplyHell(1.0, self);
  1047.         player_light1 ();
  1048.     }
  1049.     else if (self.weapon == IT_NAILGUN)
  1050.     {
  1051.         player_nail1 ();
  1052.     }
  1053.     else if (self.weapon == IT_SUPER_NAILGUN)
  1054.     {
  1055.         player_nail1 ();
  1056.     }
  1057.     else if (self.weapon == IT_GRENADE_LAUNCHER)
  1058.     {
  1059.         player_rocket1();
  1060.         W_FireGrenade();
  1061.         self.attack_finished = time + RuneApplyHell(0.6, self);
  1062.     }
  1063.     else if (self.weapon == IT_ROCKET_LAUNCHER)
  1064.     {
  1065.         player_rocket1();
  1066.         W_FireRocket();
  1067.         self.attack_finished = time + RuneApplyHell(0.8, self);
  1068.     }
  1069.     else if (self.weapon == IT_LIGHTNING)
  1070.     {
  1071.         player_light1();
  1072.         self.attack_finished = time + 0.1;
  1073.         sound (self, CHAN_AUTO, "weapons/lstart.wav", 1, ATTN_NORM);
  1074.     }
  1075. };
  1076.  
  1077. /*
  1078. ============
  1079. W_ChangeWeapon
  1080.  
  1081. ============
  1082. */
  1083. void() W_ChangeWeapon =
  1084. {
  1085.     local    float    it, am, fl; 
  1086.         
  1087.     EnableComboWeapons ( self );
  1088.     UpdateAmmoCounts ( self );
  1089.  
  1090.     it = self.items;
  1091.     am = 0;
  1092.     
  1093.     if (self.impulse == 1)
  1094.     {
  1095. //ZOID--
  1096.         if (self.weapon == IT_AXE && deathmatch && teamplay >= TEAM_CTF)
  1097.             fl = IT_GRAPPLE;
  1098.         else
  1099.             fl = IT_AXE;
  1100.     }
  1101.     else if (self.impulse == 22)
  1102.     {
  1103.         if(deathmatch && teamplay >= TEAM_CTF)        //pgm optimization
  1104.             fl = IT_GRAPPLE;
  1105.     }
  1106. //--ZOID
  1107.     else if (self.impulse == 2)
  1108.     {
  1109.         fl = IT_SHOTGUN;
  1110.         if (self.ammo_shells1 < 1)
  1111.             am = 1;
  1112.     }
  1113.     else if (self.impulse == 3)
  1114.     {
  1115.         fl = IT_SUPER_SHOTGUN;
  1116.         if (self.ammo_shells1 < 2)
  1117.             am = 1;
  1118.     }    
  1119.     else if (self.impulse == 4)
  1120.     {
  1121.         if ((self.items & IT_LAVA_NAILGUN) && 
  1122.                 (self.weapon == IT_NAILGUN || self.ammo_nails1 < 1))
  1123.         {
  1124.             fl = IT_LAVA_NAILGUN;
  1125.             if (self.ammo_lava_nails < 1)
  1126.                 am = 1;
  1127.         }
  1128.         else
  1129.         {
  1130.             fl = IT_NAILGUN;
  1131.             if (self.ammo_nails1 < 1)
  1132.                 am = 1;
  1133.         }
  1134.     }
  1135.     else if (self.impulse == 5)
  1136.     {
  1137.         if ((self.items & IT_LAVA_SUPER_NAILGUN) && 
  1138.                 (self.weapon == IT_SUPER_NAILGUN || self.ammo_nails1 < 2))
  1139.         {
  1140.             fl = IT_LAVA_SUPER_NAILGUN;
  1141.             if (self.ammo_lava_nails < 2)
  1142.                 am = 1;
  1143.         }
  1144.         else
  1145.         {
  1146.             fl = IT_SUPER_NAILGUN;
  1147.             if (self.ammo_nails1 < 2)
  1148.                 am = 1;
  1149.         }
  1150.     }
  1151.     else if (self.impulse == 6)
  1152.     {
  1153.         if ((self.items & IT_MULTI_GRENADE) && 
  1154.                 (self.weapon == IT_GRENADE_LAUNCHER || self.ammo_rockets1 < 1))
  1155.         {
  1156.             fl = IT_MULTI_GRENADE;
  1157.             if (self.ammo_multi_rockets < 1)
  1158.                 am = 1;
  1159.         }
  1160.         else
  1161.         {
  1162.             fl = IT_GRENADE_LAUNCHER;
  1163.             if (self.ammo_rockets1 < 1)
  1164.                 am = 1;
  1165.         }
  1166.     }
  1167.     else if (self.impulse == 7)
  1168.     {
  1169.         if ((self.items & IT_MULTI_ROCKET) && 
  1170.             (self.weapon == IT_ROCKET_LAUNCHER || self.ammo_rockets1 < 1))
  1171.         {
  1172.             fl = IT_MULTI_ROCKET;
  1173.             if (self.ammo_multi_rockets < 1)
  1174.                 am = 1;
  1175.         }
  1176.         else
  1177.         {
  1178.             fl = IT_ROCKET_LAUNCHER;
  1179.             if (self.ammo_rockets1 < 1)
  1180.                 am = 1;
  1181.         }
  1182.     }
  1183.     else if (self.impulse == 8)
  1184.     {
  1185.         if ((self.items & IT_PLASMA_GUN) && 
  1186.                 (self.weapon == IT_LIGHTNING || self.ammo_cells1 < 1))
  1187.         {
  1188.             fl = IT_PLASMA_GUN;
  1189.             if (self.ammo_plasma < 1)
  1190.                 am = 1;
  1191.         }
  1192.         else
  1193.         {
  1194.             fl = IT_LIGHTNING;
  1195.             if (self.ammo_cells1 < 1)
  1196.                 am = 1;
  1197.         }
  1198.     }
  1199.     else if (self.impulse == 60)
  1200.     {
  1201.         fl = IT_LAVA_NAILGUN;
  1202.         if (self.ammo_lava_nails < 1)
  1203.             am = 1;
  1204.     }
  1205.     else if (self.impulse == 61)
  1206.     {
  1207.         fl = IT_LAVA_SUPER_NAILGUN;
  1208.         if (self.ammo_lava_nails < 1)
  1209.             am = 1;
  1210.     }
  1211.     else if (self.impulse == 62)
  1212.     {
  1213.         fl = IT_MULTI_GRENADE;
  1214.         if (self.ammo_multi_rockets < 1)
  1215.             am = 1;
  1216.     }
  1217.     else if (self.impulse == 63)
  1218.     {
  1219.         fl = IT_MULTI_ROCKET;
  1220.         if (self.ammo_multi_rockets < 1)
  1221.             am = 1;
  1222.     }
  1223.     else if (self.impulse == 64)
  1224.     {
  1225.         fl = IT_PLASMA_GUN;
  1226.         if (self.ammo_plasma < 1)
  1227.             am = 1;
  1228.     }
  1229.  
  1230.     self.impulse = 0;
  1231.     
  1232.     if (!(self.items & fl))
  1233.     {    // don't have the weapon or the ammo
  1234.         sprint (self, "no weapon.\n");
  1235.         return;
  1236.     }
  1237.  
  1238.     if (am)
  1239.     {    // don't have the ammo
  1240.         sprint (self, "not enough ammo.\n");
  1241.         return;
  1242.     }
  1243.  
  1244. // from McBain:  save current weapon   -geezer
  1245. // For explicite weapon selection, allow previous weapon and new weapon to be
  1246. // same except for IT_HOOK.
  1247.         if (self.weapon != IT_GRAPPLE || fl != IT_GRAPPLE)
  1248.                 self.previous_weapon = self.weapon;
  1249.  
  1250.     
  1251.     if (self.weapon != fl)
  1252.     {
  1253.         if (self.weapon == IT_LAVA_NAILGUN || 
  1254.                 self.weapon == IT_LAVA_SUPER_NAILGUN)
  1255.         {
  1256.             if (fl == IT_NAILGUN || fl == IT_SUPER_NAILGUN)
  1257.                 sprint (self, "Normal Nails\n");
  1258.         }
  1259.         else if (self.weapon == IT_MULTI_GRENADE)
  1260.         {
  1261.             if (fl == IT_GRENADE_LAUNCHER)
  1262.                 sprint (self, "Normal Grenades\n");
  1263.         }
  1264.         else if (self.weapon == IT_MULTI_ROCKET)
  1265.         {
  1266.             if (fl == IT_ROCKET_LAUNCHER)
  1267.                 sprint (self, "Normal Rockets\n");
  1268.         }
  1269.         else if (self.weapon == IT_PLASMA_GUN)
  1270.         {
  1271.             if (fl == IT_LIGHTNING)
  1272.                 sprint (self, "Lightning Gun\n");
  1273.         }
  1274.         else if (fl == IT_LAVA_NAILGUN || fl == IT_LAVA_SUPER_NAILGUN)
  1275.         {
  1276.             sprint (self, "Lava Nails!\n");
  1277.         }
  1278.         else if(fl == IT_MULTI_GRENADE)
  1279.         {
  1280.             sprint (self, "Multi-Grenades!\n");
  1281.         }
  1282.         else if(fl == IT_MULTI_ROCKET)
  1283.         {
  1284.             sprint (self, "Multi-Rockets!\n");
  1285.         }
  1286.         else if(fl == IT_PLASMA_GUN)
  1287.         {
  1288.             sprint (self, "Plasma Gun!\n");
  1289.         }
  1290.     }
  1291.     
  1292. //
  1293. // set weapon, set ammo
  1294. //    
  1295.     self.weapon = fl;
  1296.     W_SetCurrentAmmo ();
  1297. };
  1298.  
  1299. /*
  1300. ============
  1301. CheatCommand
  1302. ============
  1303. */
  1304. void() CheatCommand =
  1305. {
  1306.     if (deathmatch || coop)
  1307.         return;
  1308.  
  1309.     self.ammo_rockets1 = 100;
  1310.     self.ammo_nails1 = 200;
  1311.     self.ammo_shells1 = 100;
  1312.     
  1313.     self.items = self.items | 
  1314.         IT_AXE |
  1315.         IT_SHOTGUN |
  1316.         IT_SUPER_SHOTGUN |
  1317.         IT_NAILGUN |
  1318.         IT_SUPER_NAILGUN |
  1319.         IT_GRENADE_LAUNCHER |
  1320.         IT_ROCKET_LAUNCHER |
  1321.         IT_LAVA_NAILGUN | 
  1322.         IT_LAVA_SUPER_NAILGUN | 
  1323.         IT_MULTI_GRENADE |
  1324.         IT_MULTI_ROCKET | 
  1325.         IT_PLASMA_GUN | 
  1326.         IT_LIGHTNING;
  1327.             
  1328.     self.items = self.items | IT_KEY1 | IT_KEY2;        
  1329.  
  1330.     self.ammo_lava_nails = 200;
  1331.     self.ammo_multi_rockets = 100;
  1332.     self.ammo_plasma = 100;
  1333.     self.ammo_cells1 = 200;
  1334.  
  1335.     self.weapon = IT_ROCKET_LAUNCHER;
  1336.     self.impulse = 0;
  1337.     W_SetCurrentAmmo ();
  1338. };
  1339.  
  1340. /*
  1341. ============
  1342. CycleWeaponCommand
  1343.  
  1344. Go to the next weapon with ammo
  1345. ============
  1346. */
  1347. void() CycleWeaponCommand =
  1348. {
  1349.     local    float    it, am;
  1350.     
  1351.     EnableComboWeapons ( self );
  1352.     UpdateAmmoCounts ( self );
  1353.  
  1354.     it = self.items;
  1355.     self.impulse = 0;
  1356.  
  1357. // from McBain:  save current weapon   -geezer
  1358.     self.previous_weapon = self.weapon;
  1359.  
  1360.  
  1361.     while (1)
  1362.     {
  1363.         am = 0;
  1364.  
  1365.         if (self.weapon == IT_PLASMA_GUN)
  1366.         {
  1367.             self.weapon = IT_AXE;
  1368.         }
  1369.         else if (self.weapon == IT_AXE)
  1370.         {
  1371. //ZOID--
  1372.             if (deathmatch && teamplay >= TEAM_CTF)
  1373.                 self.weapon = IT_GRAPPLE;
  1374.             else
  1375.             {
  1376.                 self.weapon = IT_SHOTGUN;
  1377.                 if (self.ammo_shells1 < 1)
  1378.                     am = 1;
  1379.             }
  1380. //--ZOID
  1381.         }
  1382.         else if (self.weapon == IT_GRAPPLE)
  1383.         {
  1384.             self.weapon = IT_SHOTGUN;
  1385.             if (self.ammo_shells1 < 1)
  1386.                 am = 1;
  1387.         }
  1388. //--ZOID
  1389.         else if (self.weapon == IT_SHOTGUN)
  1390.         {
  1391.             self.weapon = IT_SUPER_SHOTGUN;
  1392.             if (self.ammo_shells1 < 2)
  1393.                 am = 1;
  1394.         }        
  1395.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1396.         {
  1397.             self.weapon = IT_NAILGUN;
  1398.             if (self.ammo_nails1 < 1)
  1399.                 am = 1;
  1400.         }
  1401.         else if (self.weapon == IT_NAILGUN)
  1402.         {
  1403.             self.weapon = IT_LAVA_NAILGUN;
  1404.             if (self.ammo_lava_nails < 1)
  1405.                 am = 1;
  1406.         }
  1407.         else if (self.weapon == IT_LAVA_NAILGUN)
  1408.         {
  1409.             self.weapon = IT_SUPER_NAILGUN;
  1410.             if (self.ammo_nails1 < 2)
  1411.                 am = 1;
  1412.         }
  1413.         else if (self.weapon == IT_SUPER_NAILGUN)
  1414.         {
  1415.             self.weapon = IT_LAVA_SUPER_NAILGUN;
  1416.             if (self.ammo_lava_nails < 2)
  1417.                 am = 1;
  1418.         }
  1419.         else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  1420.         {
  1421.             self.weapon = IT_GRENADE_LAUNCHER;
  1422.             if (self.ammo_rockets1 < 1)
  1423.                 am = 1;
  1424.         }
  1425.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1426.         {
  1427.             self.weapon = IT_MULTI_GRENADE;
  1428.             if (self.ammo_multi_rockets < 1)
  1429.                 am = 1;
  1430.         }
  1431.         else if (self.weapon == IT_MULTI_GRENADE)
  1432.         {
  1433.             self.weapon = IT_ROCKET_LAUNCHER;
  1434.             if (self.ammo_rockets1 < 1)
  1435.                 am = 1;
  1436.         }
  1437.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1438.         {
  1439.             self.weapon = IT_MULTI_ROCKET;
  1440.             if (self.ammo_multi_rockets < 1)
  1441.                 am = 1;
  1442.         }
  1443.         else if (self.weapon == IT_MULTI_ROCKET)
  1444.         {
  1445.             self.weapon = IT_LIGHTNING;
  1446.             if (self.ammo_cells1 < 1)
  1447.                 am = 1;
  1448.         }
  1449.         else if (self.weapon == IT_LIGHTNING)
  1450.         {
  1451.             self.weapon = IT_PLASMA_GUN;
  1452.             if (self.ammo_plasma < 1)
  1453.                 am = 1;
  1454.         }
  1455.  
  1456.         if ( (it & self.weapon) && am == 0)
  1457.         {
  1458.             W_SetCurrentAmmo ();
  1459.             return;
  1460.         }
  1461.     }
  1462.  
  1463. };
  1464.  
  1465. /*
  1466. ============
  1467. CycleWeaponReverseCommand
  1468.  
  1469. Go to the prev weapon with ammo
  1470. ============
  1471. */
  1472. void() CycleWeaponReverseCommand =
  1473. {
  1474.     local    float    it, am;
  1475.     
  1476.     EnableComboWeapons ( self );
  1477.     UpdateAmmoCounts ( self );
  1478.  
  1479.     it = self.items;
  1480.     self.impulse = 0;
  1481.  
  1482. // from McBain:  save current weapon  -geezer
  1483.     self.previous_weapon = self.weapon;
  1484.  
  1485.     while (1)
  1486.     {
  1487.         am = 0;
  1488.  
  1489.         if (self.weapon == IT_PLASMA_GUN)
  1490.         {
  1491.             self.weapon = IT_LIGHTNING;
  1492.             if (self.ammo_cells1 < 1)
  1493.                 am = 1;
  1494.         }
  1495.         else if (self.weapon == IT_LIGHTNING)
  1496.         {
  1497.             self.weapon = IT_MULTI_ROCKET;
  1498.             if (self.ammo_multi_rockets < 1)
  1499.                 am = 1;
  1500.         }
  1501.         else if (self.weapon == IT_MULTI_ROCKET)
  1502.         {
  1503.             self.weapon = IT_ROCKET_LAUNCHER;
  1504.             if (self.ammo_rockets1 < 1)
  1505.                 am = 1;
  1506.         }
  1507.         else if (self.weapon == IT_ROCKET_LAUNCHER)
  1508.         {
  1509.             self.weapon = IT_MULTI_GRENADE;
  1510.             if (self.ammo_multi_rockets < 1)
  1511.                 am = 1;
  1512.         }
  1513.         else if (self.weapon == IT_MULTI_GRENADE)
  1514.         {
  1515.             self.weapon = IT_GRENADE_LAUNCHER;
  1516.             if (self.ammo_rockets1 < 1)
  1517.                 am = 1;
  1518.         }
  1519.         else if (self.weapon == IT_GRENADE_LAUNCHER)
  1520.         {
  1521.             self.weapon = IT_LAVA_SUPER_NAILGUN;
  1522.             if (self.ammo_lava_nails < 2)
  1523.                 am = 1;
  1524.         }
  1525.         else if (self.weapon == IT_LAVA_SUPER_NAILGUN)
  1526.         {
  1527.             self.weapon = IT_SUPER_NAILGUN;
  1528.             if (self.ammo_nails1 < 2)
  1529.                 am = 1;
  1530.         }
  1531.         else if (self.weapon == IT_SUPER_NAILGUN)
  1532.         {
  1533.             self.weapon = IT_LAVA_NAILGUN;
  1534.             if (self.ammo_lava_nails < 2)
  1535.                 am = 1;
  1536.         }
  1537.         else if (self.weapon == IT_LAVA_NAILGUN)
  1538.         {
  1539.             self.weapon = IT_NAILGUN;
  1540.             if (self.ammo_nails1 < 1)
  1541.                 am = 1;
  1542.         }
  1543.         else if (self.weapon == IT_NAILGUN)
  1544.         {
  1545.             self.weapon = IT_SUPER_SHOTGUN;
  1546.             if (self.ammo_shells1 < 2)
  1547.                 am = 1;
  1548.         }        
  1549.         else if (self.weapon == IT_SUPER_SHOTGUN)
  1550.         {
  1551.             self.weapon = IT_SHOTGUN;
  1552.             if (self.ammo_shells1 < 1)
  1553.                 am = 1;
  1554.         }
  1555.         else if (self.weapon == IT_SHOTGUN)
  1556.         {
  1557. //PGM
  1558.             if (deathmatch && teamplay >= TEAM_CTF)
  1559.                 self.weapon = IT_GRAPPLE;
  1560.             else
  1561.                 self.weapon = IT_AXE;
  1562. //PGM
  1563.         }
  1564. //ZOID--
  1565.         else if (self.weapon == IT_GRAPPLE) 
  1566.         {
  1567.             self.weapon = IT_AXE;
  1568.         }
  1569. //--ZOID
  1570.         else if (self.weapon == IT_AXE)
  1571.         {
  1572.             self.weapon = IT_PLASMA_GUN;
  1573.             if (self.ammo_plasma < 1)
  1574.                 am = 1;
  1575.         }
  1576.     
  1577.         if ( (it & self.weapon) && am == 0)
  1578.         {
  1579.             W_SetCurrentAmmo ();
  1580.             return;
  1581.         }
  1582.     }
  1583.  
  1584. };
  1585.  
  1586. // from McBain - modified for DOE by geezer
  1587. /*
  1588. ===========
  1589. PreviousWeaponCommand
  1590. ===========
  1591. */
  1592. void() PreviousWeaponCommand =
  1593. {
  1594.     local float fl, am;
  1595.  
  1596.     self.impulse = 0;
  1597.     am = 0;
  1598.  
  1599.     fl = self.weapon;
  1600.     self.weapon = self.previous_weapon;
  1601.     self.previous_weapon = fl;
  1602.  
  1603.     if (self.weapon == IT_SHOTGUN) {
  1604.         if (self.ammo_shells1 < 1)
  1605.             am = 1;
  1606.     }
  1607.     else if (self.weapon == IT_SUPER_SHOTGUN) {
  1608.         if (self.ammo_shells1 < 2)
  1609.             am = 1;
  1610.     }
  1611.     else if (self.weapon == IT_NAILGUN || self.weapon == IT_SUPER_NAILGUN) {
  1612.         if (self.ammo_nails1 < 1)
  1613.             am = 1;
  1614.     }
  1615.     else if (self.weapon == IT_LAVA_NAILGUN || self.weapon == IT_LAVA_SUPER_NAILGUN) {
  1616.         if (self.ammo_lava_nails < 1)
  1617.             am = 1;
  1618.     }
  1619.     else if (self.weapon == IT_GRENADE_LAUNCHER || self.weapon == IT_ROCKET_LAUNCHER) {
  1620.         if (self.ammo_rockets1 < 1)
  1621.             am = 1;
  1622.     }
  1623.     else if (self.weapon == IT_MULTI_GRENADE || self.weapon == IT_MULTI_ROCKET) {
  1624.         if (self.ammo_multi_rockets < 1)
  1625.             am = 1;
  1626.     }
  1627.     else if (self.weapon == IT_LIGHTNING) {
  1628.         if (self.ammo_cells1 < 1)
  1629.             am = 1;
  1630.     }
  1631.     else if (self.weapon = IT_PLASMA_GUN) {
  1632.         if (self.ammo_plasma < 1)
  1633.             am = 1;
  1634.     }
  1635.     // ignore AXE & GRAPPLE - no ammo needed
  1636.  
  1637.     if (am)
  1638.         self.weapon = W_BestWeapon();
  1639.  
  1640.     W_SetCurrentAmmo();
  1641. };
  1642.  
  1643.     
  1644. /*
  1645. ============
  1646. ServerflagsCommand
  1647.  
  1648. Just for development
  1649. ============
  1650. */
  1651. void() ServerflagsCommand =
  1652. {
  1653.     serverflags = serverflags * 2 + 1;
  1654. };
  1655.  
  1656. void() QuadCheat =
  1657. {
  1658.     if (deathmatch || coop)
  1659.         return;
  1660.     self.super_time = 1;
  1661.     self.super_damage_finished = time + 30;
  1662.     self.items = self.items | IT_QUAD;
  1663.     dprint ("quad cheat\n");
  1664. };
  1665.  
  1666.  
  1667. /*
  1668. ============
  1669. ImpulseCommands
  1670.  
  1671. ============
  1672. */
  1673. void() ImpulseCommands =
  1674. {
  1675.     local entity takeThisOut;
  1676.     
  1677.     if (self.impulse >= 1 && self.impulse <= 8)
  1678.         W_ChangeWeapon ();
  1679.     else if (self.impulse >= 60 && self.impulse <= 64)
  1680.         W_ChangeWeapon ();
  1681.     else if (self.impulse == 9)
  1682.         CheatCommand ();
  1683.     else if (self.impulse == 10)
  1684.         CycleWeaponCommand ();
  1685.     else if (self.impulse == 11)
  1686.         ServerflagsCommand ();
  1687.     else if (self.impulse == 12)
  1688.         CycleWeaponReverseCommand ();
  1689.  
  1690. // from McBain:  try impulse 69 first...  -geezer
  1691.     else if (self.impulse == 69) 
  1692.         PreviousWeaponCommand ();
  1693.  
  1694. //ZOID--
  1695. //teamplay stuff
  1696.     else if (self.impulse == 20)
  1697.         TossBackpack();
  1698.     else if (self.impulse == 21)
  1699.         TossWeapon();
  1700.     else if (self.impulse == 22)
  1701.     {
  1702.         if (deathmatch && teamplay >= TEAM_CTF)
  1703.             W_ChangeWeapon();
  1704.     }
  1705.     else if (self.impulse == 23)
  1706.         TeamFlagStatusReport();
  1707. //--ZOID
  1708.  
  1709.     else if (self.impulse == 255)
  1710.         QuadCheat ();
  1711.         
  1712.     self.impulse = 0;
  1713. };
  1714.  
  1715. /*
  1716. ============
  1717. W_WeaponFrame
  1718.  
  1719. Called every frame so impulse events can be handled as well as possible
  1720. ============
  1721. */
  1722. void() W_WeaponFrame =
  1723. {
  1724.     if (time < self.attack_finished)
  1725.         return;
  1726.  
  1727.     if (lavaGunFired)
  1728.     {
  1729.         if (self.weapon == IT_LAVA_NAILGUN || 
  1730.             self.weapon == IT_LAVA_SUPER_NAILGUN)
  1731.         {
  1732.             sound (self, CHAN_WEAPON, "lavagun/snail.wav", 1, ATTN_NORM);
  1733.         }
  1734.         lavaGunFired = 0;
  1735.     }
  1736.     
  1737.     if (self.impulse)
  1738.         ImpulseCommands ();
  1739.     
  1740. // check for attack
  1741.     if (self.button0)
  1742.     {
  1743.         SuperDamageSound ();
  1744.         W_Attack ();
  1745.     }
  1746. };
  1747.  
  1748. /*
  1749. ========
  1750. SuperDamageSound
  1751.  
  1752. Plays sound if needed
  1753. ========
  1754. */
  1755. void() SuperDamageSound =
  1756. {
  1757.     if (self.super_damage_finished > time)
  1758.     {
  1759.         if (self.super_sound < time)
  1760.         {
  1761.             self.super_sound = time + 1;
  1762.             sound (self, CHAN_BODY, "items/damage3.wav", 1, ATTN_NORM);
  1763.         }
  1764.     }
  1765.     return;
  1766. };
  1767.  
  1768.  
  1769.